/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sadhar.sipp.unkerja;

import org.sadhar.sia.framework.ClassApplicationModule;
import org.zkoss.zul.Label;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;
import org.sadhar.sipp.unkerja.*;

/**
 *
 * @author Yohan Hardinugroho
 */
public class UnitKerjaPopupWndOnLaporanAnggaranPendapatanDanaBantuanPemerintah extends ClassApplicationModule {

    private Listbox lstboxUnitKerja;
    private Textbox txtboxSearch;
    private UnKerjaDAO unKerjaDAO;
    private Label lblNamaUnitKerja;
    private Label lblUnitKerja2;

    public UnitKerjaPopupWndOnLaporanAnggaranPendapatanDanaBantuanPemerintah() {
        unKerjaDAO = new UnKerjaDAOImpl();

    }

    public void onCreate() throws Exception {
        lstboxUnitKerja = (Listbox) getFellow("lstboxUnitKerja");
        txtboxSearch = (Textbox) getFellow("txtboxSearch");
        load();
    }

    public void load() throws Exception {
        lstboxUnitKerja.getItems().clear();
        int no = 1;
        for (UnKerja unitKerja : unKerjaDAO.listpopbanpem(txtboxSearch.getValue())) {

            Listitem item = new Listitem();
            item.setValue(unitKerja);
            item.appendChild(new Listcell(unitKerja.getKdUnitKerja()));
            item.appendChild(new Listcell(unitKerja.getNamaUnitKerja()));
            lstboxUnitKerja.appendChild(item);
        }
    }

    public void lstboxUnitKerjaOnSelect() throws Exception {
        Window window = (Window)this.getParent();
        Textbox txtboxKeySearch = (Textbox) window.getFellow("txtboxKeySearch");
        Textbox txtboxKd_unit_kerja = (Textbox) window.getFellow("txtboxKd_unit_kerja");
        Label lblNamaUnitKerjas = (Label) window.getFellow("lblUnitKerja");
        /*
        Label lblNamaPosBiaya=(Label)window.getFellow("lblNamaPosBiaya");
        Label lblPengurusBiaya=(Label)window.getFellow("lblPengurusBiaya");

        txtboxIdPosBiaya.setValue(posBiaya.getKodePosBiaya()+"");
        lblNamaPosBiaya.setValue(posBiaya.getNamaPosBiaya());
        KelompokPengurusBiaya pengurusBiaya=kelompokPengurusBiayaDAO.select(posBiaya.getKodeKelompokPengurusBiaya());
        lblPengurusBiaya.setValue(pengurusBiaya.getNamaKelompokPengurusBiaya());

         */
        UnKerja unKerja = (UnKerja) lstboxUnitKerja.getSelectedItem().getValue();
        txtboxKeySearch.setValue(unKerja.getNamaUnitKerja());
        txtboxKd_unit_kerja.setValue(unKerja.getKdUnitKerja() + "");
        lblNamaUnitKerjas.setValue(unKerja.getNamaUnitKerja());
        this.detach();
    }
}
